import rsa
import time

print('''
    easyRSA - It just encrypt and decrypt
    Copyright (C) 2021  stak
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
''')

(pubkey, privkey) = rsa.newkeys(1024)

def encryption(message):
    pubkey_pem = pubkey.save_pkcs1()
    private_pem = privkey.save_pkcs1()
    global encrypted_message
    encrypted_message = rsa.encrypt(message, pubkey)
    return encrypted_message

def unencryption(encrypted_message):
    unencrypted_message = rsa.decrypt(encrypted_message, privkey)
    global decode_message
    decode_message = unencrypted_message.decode('utf-8')
    return decode_message

def console_picture():
    time.sleep(0.15)
    print("                **    **  ********  **        **            **      ")
    time.sleep(0.15)
    print("               **    **  ********  **        **         **     **   ")
    time.sleep(0.15)
    print("              ********  **        **        **         **      **  ")
    time.sleep(0.15)
    print("             ********  ********  **        **         **      **  ")
    time.sleep(0.15)
    print("            **    **  **        **        **         **      **  ")
    time.sleep(0.15)
    print("           **    **  ********  ********  ********    **    **   ")
    time.sleep(0.15)
    print("          **    **  ********  ********  ********       **      ")

def main():
    console_picture()
    message = input('Введите слово для ширования: ').encode('utf-8')
    input('Press enter to continue: ')
    encryption(message)
    unencryption(encrypted_message)
    print(encrypted_message)
    print(decode_message)

if __name__ == "__main__":
    main()
